package com.test.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by jl on 2016/5/21.
 */
public class ProxyHandler implements InvocationHandler {
    private Object realSubject;

    public ProxyHandler(Object _realSubject) {
        realSubject = _realSubject;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //doSth before
        //call the method
        return method.invoke(realSubject, args);
        //doSth after
    }
}
